2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #import "AIContactProfilePane.h"
18 #import <Adium/AIContentControllerProtocol.h>
19 #import <AIUtilities/AIAttributedStringAdditions.h>
20 #import <AIUtilities/AILinkTextView.h>
21 #import <AIUtilities/AITextAttributes.h>
22 #import <Adium/AIListContact.h>
23 #import <Adium/AIListObject.h>
24 #import "AILocalizationTextField.h"
27 * @class AIContactProfilePane
28 * @brief Pane for contact info and profile
32 @implementation AIContactProfilePane
37 - (AIContactInfoCategory)contactInfoCategory{
38 return AIInfo_Profile;
43 - (NSString *)nibName{
44 return @"ContactProfilePane";
47 //Configure the preference view
52 [label_status setLocalizedString:[AILocalizedString(@"Status",nil) stringByAppendingString:AILocalizedString(@":", nil)]];
53 [label_profileIfAvailable setLocalizedString:AILocalizedString(@"Profile (if available):",nil)];
55 [[adium contactController] registerListObjectObserver:self];
58 //Preference view is closing
62 [[adium contactController] unregisterListObjectObserver:self];
63 [listObject release]; listObject = nil;
66 //Configure the pane for a list object
67 - (void)configureForListObject:(AIListObject *)inObject
70 if (inObject != listObject) {
72 listObject = [inObject retain];
75 //Display what we have now
78 //Refresh the window's content (Contacts only)
79 if ([listObject isKindOfClass:[AIListContact class]]) {
80 [[adium contactController] updateListContactStatus:(AIListContact *)listObject];
84 //Refresh if changes are made to the object we're displaying
85 - (NSSet *)updateListObject:(AIListObject *)inObject keys:(NSSet *)inModifiedKeys silent:(BOOL)silent
87 if (inObject == listObject) {
93 //Update our pane to reflect our contact
97 [[adium contentController] filterAttributedString:([listObject isKindOfClass:[AIListContact class]] ?
98 [(AIListContact *)listObject profile] :
100 usingFilterType:AIFilterDisplay
101 direction:AIFilterIncoming
102 filterContext:listObject
104 selector:@selector(gotFilteredProfile:context:)
107 [[adium contentController] filterAttributedString:[listObject statusMessage]
108 usingFilterType:AIFilterDisplay
109 direction:AIFilterIncoming
110 filterContext:listObject
112 selector:@selector(gotFilteredStatus:context:)
116 - (void)gotFilteredProfile:(NSAttributedString *)infoString context:(AIListObject *)object
119 [self setAttributedString:infoString intoTextView:textView_profile];
122 - (void)gotFilteredStatus:(NSAttributedString *)infoString context:(AIListObject *)object
125 [self setAttributedString:infoString intoTextView:textView_status];
129 - (void)setAttributedString:(NSAttributedString *)infoString intoTextView:(NSTextView *)textView
131 NSColor *backgroundColor = nil;
133 if (infoString && [infoString length]) {
134 [[textView textStorage] setAttributedString:infoString];
135 backgroundColor = [infoString attribute:AIBodyColorAttributeName
137 longestEffectiveRange:nil
138 inRange:NSMakeRange(0,[infoString length])];
140 [[textView textStorage] setAttributedString:[NSAttributedString stringWithString:@""]];
142 [textView setBackgroundColor:(backgroundColor ? backgroundColor : [NSColor whiteColor])];
143 [[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidChangeNotification object:textView];